
/* File name	: run.h
 * Project 		: BKIT MCR
 * Version 		: 1.0
 * Creation Date: 07/07/2010
 * Tabsize		: 4
 * Author  		: BKIT4U                   
 * Copyright	: (c) 2010 BKIT HARDWARE CLUB - www.bkit4u.com
 * License		: Free.
 * Comments		: 
 * 
 */
#ifndef _RUN_H_
#define _RUN_H_

#define         MASK2_2         0x66    /* xooxxoox                     */
#define         MASK2_0         0xc0    /* ooxxxxxx                     */
#define         MASK0_2         0x03    /* xxxxxxoo                     */
#define         MASK3_3         0xe7    /* oooxxooo                     */
#define         MASK0_3         0x07    /* xxxxxooo                     */
#define         MASK3_0         0xe0    /* oooxxxxx                     */
#define         MASK4_0         0xf0    /* ooooxxxx                     */
#define         MASK0_4         0x0f    /* xxxxoooo                     */
#define         MASK1_1         0x81    /* oxxxxxxo                     */
#define			MASK4_4			0xff	/* oooooooo						*/


/*======================================*/
/* Prototype declaration                */
/*======================================*/
void run();
int check_crossline( void );
unsigned char sensor_inp( unsigned char mask );

char unsigned bit_change( char unsigned in );
void handleAndSpeed (int angle,int speed);
int check_crosshalfline(void);
void runforwardline (int tocdo);
void forwardline(int);
int gocturn90(int tocdo);
int left_lance (int tocdo);
int right_lance (int tocdo);
void khoidong(void);
void brake(int);
void brake_timer(int,int);

/*======================================*/
/* Global Variable Declaration          */
/*======================================*/
               
extern int vitri;
extern int currentangle;
extern int tempangle;
extern int	enablebrake;
extern int brake_flag;
extern int timerbrake;
extern int timerbrakechuyenlan;
extern int timerbraketurn90;
extern int line;

#endif
